Skip to content

test: TDD hardening + fuzz coverage for table conversion (#6)#8

Merged
aqueeb merged 2 commits into
mainfrom
test/harden-table-conversion
Jul 3, 2026
Merged

test: TDD hardening + fuzz coverage for table conversion (#6)#8
aqueeb merged 2 commits into
mainfrom
test/harden-table-conversion

Conversation

@aqueeb

@aqueeb aqueeb commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #7 that hardens the table list/header-row conversion using a test-first (TDD) loop, plus active fuzzing. No behavior change for well-formed Confluence exports; this closes real edge-case gaps and locks them with tests.

Test-first process (red → green)

Three tests were written first and confirmed failing against the merged code, then fixed:

Edge case Was (red) Now (green)
Empty <li></li> items stray / N. bullets with no text empty items dropped
Source text containing the internal sentinel turned into a spurious <br> sentinel stripped from input
First row mixing <th>+<td> wrongly promoted to <thead> promoted only when the row is all-<th>

Regression locks (green)

Inline formatting/links inside list items (• **bold**, • [link](url)), separate <ol> lists restart numbering, multiple tables each promoted, and header-only tables convert without falling back to raw HTML.

Fuzzing

  • Added FuzzPreProcessHTML seeds: lists in cells, nested/malformed lists, header rows in <tbody>, mixed th/td, many empty <li>, sentinel-like text.
  • Added FuzzPostProcessMarkdown seeds exercising the intra-cell sentinel.
  • Ran active fuzzing 45s on each target (≈521K + 223K executions) — no crashers. (Go's RE2 regexp is linear-time, so ReDoS isn't a concern; fuzzing targeted panics/invariants/logic.)

Coverage

flattenCellLists, cleanListItemText, promoteTableHeaderRows100% statement coverage.

Verification

go test ./... -race green · go vet ./... clean · gofmt clean on markdown.go/markdown_test.go.

Notes

  • Dropped the originally-planned idempotency test: it conflicts by design with the sentinel-strip (which removes sentinels from input), and preProcessHTML only ever runs once per document.
  • Out of scope: converter/fuzz_test.go (and mime_test.go, main_test.go) carry pre-existing CRLF line endings that gofmt flags under Go 1.25; CI (Go 1.21 golangci-lint) does not gate on this. Happy to send a separate line-ending-normalization PR if wanted.

🤖 Generated with Claude Code

aqueeb and others added 2 commits July 2, 2026 21:08
Follow-up hardening for the table list/header conversion, developed test-first
(each test below was confirmed failing before the fix):

- Drop empty <li> items so they don't leave a stray "•"/"N." with no text.
- Strip any pre-existing intra-cell sentinel from the input so source content
  can never inject a spurious <br> line break.
- Promote a table's first row into <thead> only when it is a genuine, all-<th>
  header row (a row mixing <th> and <td> is left in the body).

Adds unit + end-to-end regression tests and brings flattenCellLists,
cleanListItemText, and promoteTableHeaderRows to 100% statement coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Aqueeb Qadri <aqueeb@gmail.com>
Add FuzzPreProcessHTML seeds for lists inside table cells, header-row
promotion, mixed th/td rows, malformed/unclosed lists, empty items, and
sentinel-like text; add FuzzPostProcessMarkdown seeds exercising the intra-cell
line-break sentinel. Active fuzzing (45s each) surfaced no crashers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Aqueeb Qadri <aqueeb@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@aqueeb
aqueeb merged commit 90b62e1 into main Jul 3, 2026
5 checks passed
@aqueeb
aqueeb deleted the test/harden-table-conversion branch July 3, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants